package com.thb.pay;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Hello world!
 */
@Slf4j
@RestController
@SpringBootApplication
public class App extends SpringBootServletInitializer {


    @Autowired
    private CacheOnlineEventPublisher cacheOnlineEventPublisher;

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(App.class);
    }

    @GetMapping("/index")
    public String index() {
        cacheOnlineEventPublisher.publishEvent(new CacheOnlineEvent(CacheOnlineEvent.CONNECTION_STATUS));
        return "Hello world";
    }

}
